/*
 * Copyright 2018 the original author or authors.
 *
 * you can use the file or import project.but Do not take legal responsibility. Only for learning
 * communication.
 *
 * Java compiled version 1.8 or higher
 *
 *
 *
 *
 */

package org.liang.javasource.bean;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
 * javabean基本信息
 * 
 * @author houliang
 * @date 2018年3月5日
 */
public class BeanInfo implements Cloneable {
	private String className;// 类名
	private String classComment = "";// 类注释
	private String author;// 作者
	private String classPackage;// 包
	private String classPath;// 类路径
	public boolean cover = false;// 是否覆盖已经存在的文件，默认不覆盖，如果存在跳过
	private boolean baseDtoRule = false;// 是否使用baseDto最为父类，规则是：request的使用baseDto作为父类，response使用resultBaseDto
	private String parentClass = "";// 父类，当baseDtoRule为true时才生效
	private List<BeanAttrsInfo> attrList;// 属性列表

	private Set<String> importPackage;// 导入包

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public String getClassComment() {
		return classComment;
	}

	public void setClassComment(String classComment) {
		this.classComment = classComment;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getClassPackage() {
		return classPackage;
	}

	public void setClassPackage(String classPackage) {
		this.classPackage = classPackage;
	}

	public String getClassPath() {
		return classPath;
	}

	public void setClassPath(String classPath) {
		this.classPath = classPath;
	}

	public List<BeanAttrsInfo> getAttrList() {
		return attrList;
	}

	public void setAttrList(List<BeanAttrsInfo> attrList) {
		this.attrList = attrList;
	}

	public Set<String> getImportPackage() {
		return importPackage;
	}

	public void setImportPackage(Set<String> importPackage) {
		this.importPackage = importPackage;
	}

	public boolean isBaseDtoRule() {
		return baseDtoRule;
	}

	public void setBaseDtoRule(boolean baseDtoRule) {
		this.baseDtoRule = baseDtoRule;
	}

	public String getParentClass() {
		return parentClass;
	}

	public void setParentClass(String parentClass) {
		this.parentClass = parentClass;
	}

	@Override
	public BeanInfo clone() {
		BeanInfo beanInfo = null;
		try {
			beanInfo = (BeanInfo) super.clone();
			if (this.attrList != null && this.attrList.size() > 0) {
				List<BeanAttrsInfo> copy = new ArrayList<BeanAttrsInfo>();
				for (BeanAttrsInfo beanAttrsInfo : this.attrList) {
					copy.add(beanAttrsInfo.clone());
				}
				beanInfo.setAttrList(copy);
			}
			if (this.importPackage.size() > 0) {
				Set<String> newCopy = new HashSet<String>();
				Iterator<String> it = this.importPackage.iterator();
				while (it.hasNext()) {
					newCopy.add(it.next());
				}
				beanInfo.setImportPackage(newCopy);
			}
		} catch (CloneNotSupportedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return beanInfo;
	}
}
